<?php
declare(strict_types=1);
namespace Field;

class SysUserBalanceLogConst
{
    public const pk='BalanceID';
    public const index=['BalanceID'];
	public const fields=['BalanceID','UserID','ParentUserID','FromUserID','TypeID','Channel','Balance','CreateAt','Status','FrozenAt','OrderID','Remak'];
	public const comment=['BalanceID'=>'id','UserID'=>'','ParentUserID'=>'','FromUserID'=>'来源用户','TypeID'=>'类型 10收入 20支出','Channel'=>'类型','Balance'=>'金额','CreateAt'=>'时间','Status'=>'0未生效 1有效 2取消 3退款 4冻结','FrozenAt'=>'可用时间','OrderID'=>'订单号','Remak'=>'备注'];
	/*
    * @Field BalanceID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment id
    */
    public const BalanceID = 'BalanceID';
    /*
    * @Field UserID
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UserID = 'UserID';
    /*
    * @Field ParentUserID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const ParentUserID = 'ParentUserID';
    /*
    * @Field FromUserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 来源用户
    */
    public const FromUserID = 'FromUserID';
    /*
    * @Field TypeID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 类型 10收入 20支出
    */
    public const TypeID = 'TypeID';
    /*
    * @Field Channel
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 类型
    */
    public const Channel = 'Channel';
    /*
    * @Field Balance
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 金额
    */
    public const Balance = 'Balance';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 0未生效 1有效 2取消 3退款 4冻结
    */
    public const Status = 'Status';
    /*
    * @Field FrozenAt
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 可用时间
    */
    public const FrozenAt = 'FrozenAt';
    /*
    * @Field OrderID
    * @Type char(20)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 订单号
    */
    public const OrderID = 'OrderID';
    /*
    * @Field Remak
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 备注
    */
    public const Remak = 'Remak';
}

class SysUserBalanceLogColumns
{
public  int $BalanceID;
   public  int $UserID;
   public  int $ParentUserID=0;
   public  int $FromUserID=0;
   public  int $TypeID=0;
   public  int $Channel=0;
   public  int $Balance=0;
   public  ?string $CreateAt='';
   public  int $Status=0;
   public  int $FrozenAt=0;
   public  ?string $OrderID='';
   public  ?string $Remak='';
	public function toArray():array
	{
		return [
'BalanceID'=>$this->BalanceID,
    'UserID'=>$this->UserID,
    'ParentUserID'=>$this->ParentUserID,
    'FromUserID'=>$this->FromUserID,
    'TypeID'=>$this->TypeID,
    'Channel'=>$this->Channel,
    'Balance'=>$this->Balance,
    'CreateAt'=>$this->CreateAt,
    'Status'=>$this->Status,
    'FrozenAt'=>$this->FrozenAt,
    'OrderID'=>$this->OrderID,
    'Remak'=>$this->Remak,        ];
	}
}

class SysUserBalanceLogRow
{
	public SysUserBalanceLogColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'BalanceID' => $this->data->BalanceID,
        'UserID' => $this->data->UserID,
        'ParentUserID' => $this->data->ParentUserID,
        'FromUserID' => $this->data->FromUserID,
        'TypeID' => $this->data->TypeID,
        'Channel' => $this->data->Channel,
        'Balance' => $this->data->Balance,
        'CreateAt' => $this->data->CreateAt,
        'Status' => $this->data->Status,
        'FrozenAt' => $this->data->FrozenAt,
        'OrderID' => $this->data->OrderID,
        'Remak' => $this->data->Remak, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysUserBalanceLogColumns();
        isset($data['BalanceID']) && $this->data->BalanceID = (int)$data['BalanceID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['ParentUserID']) && $this->data->ParentUserID = (int)$data['ParentUserID'];
           isset($data['FromUserID']) && $this->data->FromUserID = (int)$data['FromUserID'];
           isset($data['TypeID']) && $this->data->TypeID = (int)$data['TypeID'];
           isset($data['Channel']) && $this->data->Channel = (int)$data['Channel'];
           isset($data['Balance']) && $this->data->Balance = (int)$data['Balance'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['FrozenAt']) && $this->data->FrozenAt = (int)$data['FrozenAt'];
           isset($data['OrderID']) && $this->data->OrderID = (string)$data['OrderID'];
           isset($data['Remak']) && $this->data->Remak = (string)$data['Remak'];
    }
}
?>